package com.lh.controller;

import com.lh.entity.dto.LocateRequest;
import com.lh.entity.dto.LocateResponse;
import com.lh.service.ResponsiblePersonsService;

import com.lh.utils.Answer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/responsible")
public class ResponsiblePersonsController {

    @Autowired
    private ResponsiblePersonsService responsiblePersonsService;

    /** POST：JSON 入参 */
    @PostMapping("/locate")
    public Answer<LocateResponse> locate(@RequestBody LocateRequest req) {
        String value = responsiblePersonsService.locatePerson(req.getProcessStep(), req.getAreaKey());
        LocateResponse resp = new LocateResponse();
        resp.setProcessStep(req.getProcessStep());
        resp.setAreaKey(req.getAreaKey());
        resp.setValue(value);
        return Answer.ok(resp);
    }

    /** GET：方便直接浏览器/工具测试（可选） */
    @GetMapping("/locate")
    public Answer<LocateResponse> locateGet(@RequestParam String processStep,
                                            @RequestParam String areaKey) {
        String value = responsiblePersonsService.locatePerson(processStep, areaKey);
        LocateResponse resp = new LocateResponse();
        resp.setProcessStep(processStep);
        resp.setAreaKey(areaKey);
        resp.setValue(value);
        return Answer.ok(resp);
    }
}
